<template>
  <div class="container">
    <div>基本属性</div>
    <div class="line"></div>
    <div class="flex_row">
      <div class="row">
        <div class="font"><span style="color: red">*</span>学员姓名：</div>
        <div>
          <el-input
            v-model="studentName"
            placeholder="请输入学员姓名"
            clearable
            size="small"
          />
        </div>
      </div>
      <div class="row">
        <div class="font"><span style="color: red">*</span>性别：</div>
        <div>
          <el-select v-model="sex" placeholder="请选择学员性别">
            <el-option
              v-for="item in sexList"
              :key="item.key"
              :label="item.value"
              :value="item.key"
            ></el-option>
          </el-select>
        </div>
      </div>
    </div>
    <div class="flex_row">
      <div class="row">
        <div class="font"><span style="color: red">*</span>手机号：</div>
        <div>
          <el-input
            v-model="phonenumber"
            placeholder="请输入手机号"
            clearable
            size="small"
          />
        </div>
      </div>
      <div class="row">
        <div class="font">民族：</div>
        <div>
          <el-input
            v-model="nation"
            placeholder="请输入名族"
            clearable
            size="small"
          />
        </div>
      </div>
    </div>
    <div class="flex_row">
      <div class="row">
        <div class="font"><span style="color: red">*</span>身份证号：</div>
        <div>
          <el-input
            v-model="identificationCard"
            placeholder="请输入身份证号"
            clearable
            size="small"
          />
        </div>
      </div>
      <div class="row">
        <div class="font"><span style="color: red">*</span>学历：</div>
        <div>
          <el-select v-model="education" placeholder="请选择学历">
            <el-option
              v-for="item in educationList"
              :key="item.key"
              :label="item.value"
              :value="item.key"
            ></el-option>
          </el-select>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="font">工作年限：</div>
      <div>
        <el-input v-model="workYear" placeholder="请输入工作年限" clearable />
      </div>
    </div>
    <div class="row">
      <div class="font">工作单位：</div>
      <div>
        <el-input
          style="width: 650px"
          v-model="work"
          placeholder="请输入工作单位"
          clearable
        />
      </div>
    </div>
    <div>报考属性</div>
    <div class="line"></div>
    <div class="row">
      <div class="font"><span style="color: red">*</span>报考级别：</div>
      <div>
        <el-select v-model="testLevel" placeholder="请选择报考级别">
          <el-option
            v-for="item in levelList"
            :key="item.key"
            :label="item.value"
            :value="item.key"
          ></el-option>
        </el-select>
      </div>
      <div class="font"><span style="color: red">*</span>报考方向：</div>
      <div>
        <el-select v-model="testDirection" placeholder="请选择报考方向">
          <el-option
            v-for="item in directList"
            :key="item.key"
            :label="item.value"
            :value="item.key"
          ></el-option>
        </el-select>
      </div>
    </div>
    <div class="row">
      <div class="font">应收：</div>
      <div>
        <el-input
          v-model="receivable"
          placeholder="请输入应收价格（元）"
          clearable
        />
      </div>
      <div class="font">实收：</div>
      <div>
        <el-input
          v-model="receipts"
          placeholder="请输入实收价格（元）"
          clearable
        />
      </div>
    </div>
    <div class="row">
      <div class="font">推荐人：</div>
      <div>
        <el-input v-model="reference" placeholder="请输入推荐人" clearable />
      </div>
    </div>
    <div class="row">
      <div class="font">备注：</div>
      <div>
        <el-input
        style="width: 700px"
          v-model="remark"
          type="textarea"
          :rows="4"
          clearable
        />
      </div>
    </div>
    <div class="footer">
      <el-button @click="back()">返回</el-button>
      <el-button type="primary" @click="submit()">提交</el-button>
    </div>
  </div>
</template>

<script>
import { studentAdd } from "@/api/system/user";
export default {
  components: {},
  data() {
    return {
      studentName: "",
      sex: "",
      sexList: [
        { key: "0", value: "男" },
        { key: "1", value: "女" },
        { key: "2", value: "未知" },
      ],
      phonenumber: "",
      nation: "",
      identificationCard: "",
      education: "",
      educationList: [
        { key: "1", value: "博士及以上" },
        { key: "2", value: "硕士" },
        { key: "3", value: "本科" },
        { key: "4", value: "专科" },
        { key: "5", value: "高中" },
        { key: "6", value: "其他" },
      ],
      work: "",
      workYear: "",
      testLevel: "",
      testDirection: "",
      reference: "",
      remark: "",
      receivable: "",
      receipts: "",
      levelList: [
        { key: "1", value: "初级" },
        { key: "2", value: "中级" },
        { key: "3", value: "高级" },
        { key: "4", value: "技师（暂未开放）" },
      ],
      directList: [
        { key: "1", value: "监控方向" },
        { key: "2", value: "维保方向" },
      ],
      page: this.$route.query.page,
      personClass: this.$route.query.personClass,
    };
  },
  created() {},
  mounted() {},
  methods: {
    back() {
      this.$router.push({
        path: "studentList",
        query: { page: this.page, personClass: this.personClass },
      });
    },
    submit() {
      let params = {
        studentName: this.studentName,
        sex: this.sex,
        phonenumber: this.phonenumber,
        nation: this.nation,
        identificationCard: this.identificationCard,
        education: this.education,
        work: this.work,
        workYear: this.workYear,
        testLevel: this.testLevel,
        testDirection: this.testDirection,
        reference: this.reference,
        remark: this.remark,
        receivable: this.receivable,
        receipts: this.receipts,
      };
      var isToken = true;
      studentAdd(params, isToken).then((res) => {
        if (res.code == 200) {
          this.$message({ message: res.msg, type: "success" });
          this.$router.push({
            path: "studentList",
            query: { page: this.page, personClass: this.personClass },
          });
        } else {
          this.$message({ message: res.msg, type: "error" });
        }
      });
    },
  },
};
</script>
<style scoped>
.container {
  padding-left: 26px;
  padding-right: 24px;
  padding-top: 24px;
}
.row {
  display: flex;
  padding-bottom: 20px;
}
.line {
  height: 1px;
  background: #dcdfe6;
  width: 100%;
  margin-top: 6px;
  margin-bottom: 20px;
}
.row .font {
  width: 200px;
  text-align: right;
  margin-right: 20px;
}
.row .fonts {
  width: 300px;
  text-align: right;
  margin-right: 20px;
}
.flex_row {
  display: flex;
}
.footer {
  width: 540px;
  text-align: right;
  margin-top: 40px;
}
</style>
